#ifndef SINGLETON_H
#define SINGLETON_H


#define SINGLETON( T )  public:                                \
                            static T* instance()               \
                            {                                  \
                                if ( !my_singleton )           \
                                {                              \
                                    my_singleton = new T();    \
                                }                              \
                                return my_singleton;           \
                            }                                  \
                            static void deleteInstance()       \
                            {                                  \
                                if ( my_singleton )            \
                                {                              \
                                     delete my_singleton;      \
                                      my_singleton = NULL;     \
                                 }                             \
                            }                                  \
                        private:                               \
                            T();                               \
                            virtual ~T();                      \
                            static T* my_singleton;

#define INIT_SINGLETON( T )   T* T::my_singleton = NULL;

#endif
